package com.jin.concurrent.example.singleton;

import com.jin.concurrent.annoations.NotRecommand;
import com.jin.concurrent.annoations.ThreadSafe;

/**
 * @author JinLiu
 * <p>
 * 懒汉模式: 单例实例在第一次使用时进行创建
 */
@ThreadSafe
@NotRecommand
public class SingletonExample3 {

    // 私有构造函数
    private SingletonExample3() {
    }

    // 单例对象
    private static SingletonExample3 instance = null;

    // 静态工厂方法
    public static synchronized SingletonExample3 getInstance() {
        if (null != instance) {
            instance = new SingletonExample3();
        }

        return instance;
    }

}
